package com.taotao.controller;

import com.taotao.common.pojo.EUTreeNode;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.service.ContentCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Package com.taotao.controller
 * @Description:
 * @Author elwyn
 * @Date 2017/9/4 21:25
 * @Email elonyong@163.com
 */
@Controller
@RequestMapping("/content/category")
public class ContentCategoryController {
    @Autowired
    ContentCategoryService contentCategoryService;

    @RequestMapping("list")
    @ResponseBody
    public List<EUTreeNode> getContentCategoryList(@RequestParam(value = "id", defaultValue = "0") Long parentId) {
        List<EUTreeNode> categoryList = contentCategoryService.getCategoryList(parentId);
        return categoryList;
    }

    @RequestMapping("create")
    @ResponseBody
    public TaotaoResult createContentCategory(Long parentId, String name) {
        TaotaoResult taotaoResult = contentCategoryService.insertContentCategory(parentId, name);
        return taotaoResult;
    }
}
